<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 它把数组的这些方法做了一个重新包裹 -->
      <!-- 所以才能侦听到 -->
      <button @click="list.push(99)">添加元素</button>
      <ul>
        <li v-for="item in list">{{ item }}</li>
      </ul>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        data () {
          return {
            list: [10, 20, 30]
          }
        },
        watch: {
            list () {
                console.log('数组变化了')
            }
        }
      })
    </script>
  </body>
</html>
